home *** CD-ROM | disk | FTP | other *** search
/ Gigantic Games 2 / Gigantic Games 2.iso / pc / _a_ / attacks / sources / input.mod < prev    next >
Text File  |  1994-12-23  |  24KB  |  622 lines

  1. IMPLEMENTATION MODULE input;
  2.  
  3. (*$R-*) (* range checking OFF *)
  4.  
  5.  
  6. (*   This module deals with all the input of the program, Ataxx.  It must *)
  7. (* be linked with the graphics module, because the IDCMP events are       *)
  8. (* linked to the window.  Therefore, some of the structures that should   *)
  9. (* be hidden in the ataxxgraphics module are visible so that this module  *)
  10. (* can use them.  The only procedure visible here is GetEvent.            *)
  11.  
  12.  
  13. FROM header
  14.   IMPORT   playertype, movetype, boardrange, boardtype, state,
  15.            squaretype,          (* Strangely, it's necessary to compile!  *)
  16.            gameover, pointercode, difficulty, whoisred, whoisblue,
  17.            thinkertype;
  18. FROM attacksgraphics
  19.   IMPORT   mywindowptr,         (* Necessary for getting IDCMP events  *)
  20.            HighlightSquare, UnHighlightSquare, ChangePointer,
  21.            DrawBoard, DrawSquare, PrintTurn;
  22. FROM mdgenerallib
  23.   IMPORT MyPause;
  24. FROM Ports
  25.   IMPORT   GetMsg, ReplyMsg, MsgPortPtr, WaitPort, MessagePtr;
  26. FROM Tasks
  27.   IMPORT SignalSet, Wait;
  28. FROM SYSTEM
  29.   IMPORT ADDRESS, LONGWORD;
  30. FROM Intuition
  31.   IMPORT   IntuiMessagePtr, SelectDown, SelectUp, SetMenuStrip,
  32.            ClearMenuStrip, IDCMPFlagsSet, IDCMPFlags, MENUNUM, ITEMNUM,
  33.            MenuItemMutualExcludeSet;
  34. FROM MenuUtil
  35.   IMPORT   MENUBARPTR, InitMenuBar, ArrangeMenus, AddMenu, AddItem,
  36.            DisposeMenuBar;
  37.  
  38. VAR
  39.   mymsgportptr : MsgPortPtr;       (* Points to my message port     *)
  40.   mousex, mousey : INTEGER;        (* The coordinates of last IDCMP event *)
  41.  
  42.   mymenuptr : MENUBARPTR;          (* For Chris' menu routines *)
  43.  
  44.   editpointerstate : squaretype;   (* This tells what the state of the *)
  45.                                    (*  pointer is during editing.      *)
  46.  
  47. (**************************************************************************)
  48. PROCEDURE InitMenus;
  49.  
  50. (*   This initializes the menus for the program.  Simple.                 *)
  51. (*                                                                        *)
  52. (*   INPUT                                                                *)
  53. (*            n/a                                                         *)
  54. (*                                                                        *)
  55. (*   OUTPUT                                                               *)
  56. (*            The menus for the program now should work.                  *)
  57. (*                                                                        *)
  58.  
  59. BEGIN
  60.   InitMenuBar(mymenuptr);
  61.  
  62.   AddMenu(mymenuptr, "Project");        (* First menu *)
  63.   AddItem(mymenuptr, "New Game    ", "N", MenuItemMutualExcludeSet{}, FALSE);
  64.   AddItem(mymenuptr, "Edit Board    ", "E", MenuItemMutualExcludeSet{}, FALSE);
  65.   AddItem(mymenuptr, "About", 0C, MenuItemMutualExcludeSet{}, FALSE);
  66.   AddItem(mymenuptr, "Quit    ", "Q", MenuItemMutualExcludeSet{}, FALSE);
  67.  
  68.   AddMenu(mymenuptr, "Commands");
  69.   AddItem(mymenuptr, "Backup a move    ", "B", MenuItemMutualExcludeSet{}, FALSE);
  70.   AddItem(mymenuptr, "Redo a move    ", "R", MenuItemMutualExcludeSet{}, FALSE);
  71.   AddItem(mymenuptr, "Force Computer to move    ", "F", MenuItemMutualExcludeSet{}, FALSE);
  72.  
  73.   AddMenu(mymenuptr, "Options");         (* Second menu *)
  74.   AddItem(mymenuptr, "  Red is Human", 0C, MenuItemMutualExcludeSet{1}, whoisred = human);
  75.   AddItem(mymenuptr, "  Red is Computer", 0C, MenuItemMutualExcludeSet{0}, whoisred = computer);
  76.   AddItem(mymenuptr, "  Blue is Human", 0C, MenuItemMutualExcludeSet{3}, whoisblue = human);
  77.   AddItem(mymenuptr, "  Blue is Computer", 0C, MenuItemMutualExcludeSet{2}, whoisblue = computer);
  78.   AddItem(mymenuptr, "", 0C, MenuItemMutualExcludeSet{}, FALSE);
  79.   AddItem(mymenuptr, "  Tries to Lose", 0C, MenuItemMutualExcludeSet{6,7,8,9}, difficulty = 0);
  80.   AddItem(mymenuptr, "  Easy", 0C, MenuItemMutualExcludeSet{5,7,8,9}, difficulty = 1);
  81.   AddItem(mymenuptr, "  Kinda' Good", 0C, MenuItemMutualExcludeSet{5,6,8,9}, difficulty = 2);
  82.   AddItem(mymenuptr, "  Good", 0C, MenuItemMutualExcludeSet{4,5,7,9}, difficulty = 3);
  83.   AddItem(mymenuptr, "  Very Good", 0C, MenuItemMutualExcludeSet{5,6,7,8}, difficulty = 4);
  84.  
  85.   ArrangeMenus(mymenuptr);
  86.   SetMenuStrip( mywindowptr^, mymenuptr^.FirstMenuPtr^ );
  87. END InitMenus;
  88.  
  89.  
  90. (**************************************************************************)
  91. PROCEDURE CloseMenus;
  92.  
  93. (*   This closes and deallocates the memory for the menus.                *)
  94. (*                                                                        *)
  95. (*   INPUT                                                                *)
  96. (*            n/a                                                         *)
  97. (*                                                                        *)
  98. (*   OUTPUT                                                               *)
  99. (*            Kills the menus.                                            *)
  100. (*                                                                        *)
  101.  
  102. BEGIN
  103.   ClearMenuStrip( mywindowptr^ );
  104.   DisposeMenuBar( mymenuptr );
  105. END CloseMenus;
  106.  
  107.  
  108. (**************************************************************************)
  109. PROCEDURE ChangeToEditMenu;
  110.  
  111. (*   Clears the current menu and makes the Edit menu.                     *)
  112. (*                                                                        *)
  113. (*   INPUT                                                                *)
  114. (*            n/a                                                         *)
  115. (*                                                                        *)
  116. (*   OUTPUT                                                               *)
  117. (*            Remakes the menu bar.                                       *)
  118.  
  119. BEGIN
  120.   CloseMenus;
  121.   InitMenuBar(mymenuptr);
  122.  
  123.   AddMenu(mymenuptr, "Project");
  124.   AddItem(mymenuptr, "Exit Edit Mode", 0C, MenuItemMutualExcludeSet{}, FALSE);
  125.  
  126.   AddMenu(mymenuptr, "Player");
  127.   IF state.turn = red THEN
  128.      AddItem(mymenuptr, "  Red to move", 0C, MenuItemMutualExcludeSet {1}, TRUE);
  129.      AddItem(mymenuptr, "  Blue to move", 0C, MenuItemMutualExcludeSet {0}, FALSE);
  130.      ELSE
  131.      AddItem(mymenuptr, "  Red to move", 0C, MenuItemMutualExcludeSet {1}, FALSE);
  132.      AddItem(mymenuptr, "  Blue to move", 0C, MenuItemMutualExcludeSet {0}, TRUE);
  133.      END;
  134.  
  135.   AddMenu(mymenuptr, "Build");
  136.   AddItem(mymenuptr, "  Empty Space", 0C,
  137.           MenuItemMutualExcludeSet{1,2,3}, editpointerstate = empty);
  138.   AddItem(mymenuptr, "  Block Space", 0C,
  139.           MenuItemMutualExcludeSet{0,2,3}, editpointerstate = block);
  140.   AddItem(mymenuptr, "  Red Player", 0C,
  141.           MenuItemMutualExcludeSet{0,1,3}, editpointerstate = red);
  142.   AddItem(mymenuptr, "  Blue Player", 0C,
  143.           MenuItemMutualExcludeSet{0,1,2}, editpointerstate = blue);
  144.  
  145.   AddMenu(mymenuptr, "Major");
  146.   AddItem(mymenuptr, "Cancel All", 0C, MenuItemMutualExcludeSet{}, FALSE);
  147.   AddItem(mymenuptr, "All Empty", 0C, MenuItemMutualExcludeSet{}, FALSE);
  148.   AddItem(mymenuptr, "All Blocks", 0C, MenuItemMutualExcludeSet{}, FALSE);
  149.  
  150.   ArrangeMenus(mymenuptr);
  151.   SetMenuStrip( mywindowptr^, mymenuptr^.FirstMenuPtr^ );
  152. END ChangeToEditMenu;
  153.  
  154.  
  155. (**************************************************************************)
  156. PROCEDURE ChangeToComputerMenu;
  157.  
  158. (*   Clears the current menu and makes the menu to be displayed during    *)
  159. (* the time the computer is moving.                                       *)
  160. (*                                                                        *)
  161. (*   INPUT                                                                *)
  162. (*            n/a                                                         *)
  163. (*                                                                        *)
  164. (*   OUTPUT                                                               *)
  165. (*            Remakes the menu bar.                                       *)
  166. BEGIN
  167.   CloseMenus;
  168.   InitMenuBar(mymenuptr);
  169.  
  170.   AddMenu(mymenuptr, "Stop!");
  171.   AddItem(mymenuptr, "Abort Computer's Move    ", "A", MenuItemMutualExcludeSet{}, FALSE);
  172.  
  173.   ArrangeMenus(mymenuptr);
  174.   SetMenuStrip( mywindowptr^, mymenuptr^.FirstMenuPtr^ );
  175. END ChangeToComputerMenu;
  176.  
  177. (**************************************************************************)
  178. PROCEDURE ChangeToMainMenu;
  179.  
  180. (*   Clears the current menu and makes the regular Main menu.             *)
  181. (*                                                                        *)
  182. (*   INPUT                                                                *)
  183. (*            n/a                                                         *)
  184. (*                                                                        *)
  185. (*   OUTPUT                                                               *)
  186. (*            Remakes the menu bar.                                       *)
  187. (*                                                                        *)
  188.  
  189. BEGIN
  190.   CloseMenus;
  191.   InitMenus;
  192. END ChangeToMainMenu;
  193.  
  194.  
  195. (**************************************************************************)
  196. PROCEDURE GetPrimitiveEvent(VAR msgcode : CARDINAL;
  197.                             VAR msgclass : IDCMPFlagsSet);
  198.  
  199. (*   This is the low-level procedure that waits for an IDCMP event and    *)
  200. (* then returns the code associated with it.  This routine also replies   *)
  201. (* to Intuition quickly so that inputs don't build up (hopefully).        *)
  202. (*                                                                        *)
  203. (*   INPUT                                                                *)
  204. (*            All input comes from the USER!                              *)
  205. (*                                                                        *)
  206. (*   OUTPUT                                                               *)
  207. (*            The direct IDCMP code is returned.                          *)
  208. (*                                                                        *)
  209.  
  210. VAR
  211.   imessageptr : IntuiMessagePtr;   (* Points to an intuimessage     *)
  212.   Signals      : SignalSet;
  213.  
  214. BEGIN
  215.                              (* Waits for an IDCMP event *)
  216.   Signals :=
  217.      Wait( SignalSet{ CARDINAL(mywindowptr^.UserPort^.mpSigBit) } );
  218.  
  219.   REPEAT
  220.                           (* Takes the first event off the event queue *)
  221.     imessageptr := GetMsg(mywindowptr^.UserPort^);
  222.      IF imessageptr # NIL THEN
  223.         mousex := imessageptr^.MouseX;
  224.         mousey := imessageptr^.MouseY;
  225.         msgcode := imessageptr^.Code;
  226.         msgclass := imessageptr^.Class;
  227.         ReplyMsg(imessageptr);
  228.         END;
  229.     UNTIL imessageptr = NIL;
  230.  
  231. END GetPrimitiveEvent;
  232.  
  233.  
  234. (**************************************************************************)
  235. PROCEDURE TransCoordToBoard (screenx : INTEGER; screeny : INTEGER;
  236.                           VAR boardx : boardrange; VAR boardy : boardrange)
  237.                           : BOOLEAN;
  238.  
  239. (*      Given two coordinates representing a low resolution screen's      *)
  240. (* pixel location, this returns with the second two variables represent-  *)
  241. (* ing the corresponding location on the ataxx board.  In other words,    *)
  242. (* this finds out which square a certain pixel belongs to.  If the pixel  *)
  243. (* does not belong to a square, then the function returns FALSE.          *)
  244. (*                                                                        *)
  245. (*   INPUT                                                                *)
  246. (*            screenx, screeny     These two numbers are simply coordi-   *)
  247. (*                                 nates from the screen.  The screen     *)
  248. (*                                 is low res, so the values are 0..319   *)
  249. (*                                 and 0..199.                            *)
  250. (*                                                                        *)
  251. (*            boardx, boardy       Although they are input, they're real- *)
  252. (*                                 just considered as garbage inputs.     *)
  253. (*                                                                        *)
  254. (*   OUPUT                                                                *)
  255. (*            boardx, boardy       These numbers will reflect the square  *)
  256. (*                                 of the board where the screenx,screeny *)
  257. (*                                 pixel falls.  If the pixel is not in   *)
  258. (*                                 a square, then these are unchanged.    *)
  259. (*                                                                        *)
  260. (*            The function returns a TRUE if the pixel location was in a  *)
  261. (*            board square, and FALSE otherwise.                          *)
  262.  
  263. VAR
  264.   goodvalue : BOOLEAN;       (* Tells whether we've found a place or not  *)
  265.  
  266. BEGIN
  267.   goodvalue := FALSE;
  268.   IF (51 < screenx) AND (screenx < 268) AND       (* check range *)
  269.      (17 < screeny) AND (screeny < 199) AND
  270.      (((screenx - 51) MOD 31) # 0) AND            (* check on a line   *)
  271.      (((screeny - 17) MOD 26) # 0)
  272.      THEN
  273.         goodvalue := TRUE;
  274.         boardx := (screenx - 21) DIV 31;          (* change the values *)
  275.         boardy := (screeny + 8) DIV 26;
  276.      END;
  277.  
  278.   RETURN goodvalue;
  279.  
  280. END TransCoordToBoard;
  281.  
  282.  
  283.  
  284. (************************************************************)
  285.  
  286. PROCEDURE ProcessMenuPick( code     : CARDINAL) : eventtype;
  287.  
  288. (*      This takes a code, assuming that this is the code returned for    *)
  289. (* a menu event, and translates it into MY event code, which is returned. *)
  290. (*                                                                        *)
  291. (*   INPUT                                                                *)
  292. (*            code        This is the code that was received by the IDCMP *)
  293. (*                        input event.  The IDCMP class has already re-   *)
  294. (*                        vealed that this code is of a MenuPick class    *)
  295. (*                        (a menu event).                                 *)
  296. (*                                                                        *)
  297. (*   OUTPUT                                                               *)
  298. (*            This returns an eventtype that specifies exactly what kind  *)
  299. (*            of event occurred.  Of course this routine will only return *)
  300. (*            what kind of menu event only.                               *)
  301.  
  302. VAR
  303.   menunumber, itemnumber : CARDINAL;
  304.  
  305. BEGIN
  306.   menunumber := MENUNUM(code);
  307.   itemnumber := ITEMNUM(code);
  308.  
  309.   CASE menunumber OF            (* this is pretty simple, now.   *)
  310.      | 0  :
  311.         CASE itemnumber OF
  312.            | 0  :
  313.               RETURN NEWGAME;
  314.  
  315.            | 1  :
  316.               RETURN EDIT;
  317.  
  318.            | 2  :
  319.               RETURN ABOUT;
  320.  
  321.            | 3  :
  322.               RETURN QUIT;
  323.            END;
  324.  
  325.      | 1  :
  326.         CASE itemnumber OF
  327.            | 0  :
  328.               RETURN BACKUP;
  329.  
  330.            | 1  :
  331.               RETURN REDO;
  332.  
  333.            | 2  :
  334.               RETURN FORCE;
  335.            END;
  336.  
  337.      | 2  :
  338.         CASE itemnumber OF
  339.            | 0  :
  340.               whoisred := human;
  341.               RETURN OOPS;
  342.            | 1  :
  343.               whoisred := computer;
  344.               RETURN OOPS;
  345.            | 2  :
  346.               whoisblue := human;
  347.               RETURN OOPS;
  348.            | 3  :
  349.               whoisblue := computer;
  350.               RETURN OOPS;
  351.            | 4  :
  352.               RETURN OOPS;
  353.            | 5  :
  354.               difficulty := 0;
  355.               RETURN OOPS;
  356.            | 6  :
  357.               difficulty := 1;
  358.               RETURN OOPS;
  359.            | 7  :
  360.               difficulty := 2;
  361.               RETURN OOPS;
  362.            | 8  :
  363.               difficulty := 3;
  364.               RETURN OOPS;
  365.            | 9  :
  366.               difficulty := 4;
  367.               RETURN OOPS;
  368.            END;
  369.  
  370.      ELSE RETURN OOPS;
  371.  
  372.      END;
  373.  
  374. END ProcessMenuPick;
  375.  
  376.  
  377. (**************************************************************************)
  378.  
  379. PROCEDURE GetEvent (player : playertype) : eventtype;
  380.  
  381. (*   This procedure returns a code indicating a specific input event.     *)
  382. (* Such events are like a menu selection, or a player's move.  If the     *)
  383. (* event is a move, then the specific move will be specified in the var-  *)
  384. (* iable, moveAttempted.  It is expected that this routine will be called *)
  385. (* and then waited for until the user(s) makes some sort of imput.  It    *)
  386. (* is the responsibility of this and subordinate procedures to do the     *)
  387. (* waiting in a proper fashion.                                           *)
  388. (*                                                                        *)
  389. (*   INPUT                                                                *)
  390. (*            player      Tells the procedure who's turn it currently is. *)
  391. (*                        Necessary because this does some checking to    *)
  392. (*                        see if a correct move was made.                 *)
  393. (*                                                                        *)
  394. (*   OUTPUT                                                               *)
  395. (*            Returns a variable of eventtype that indicates the high-    *)
  396. (*            level input event.  If the event is a move by a player,     *)
  397. (*            then the variable moveAttempted will hold the move.         *)
  398.  
  399. VAR
  400.   msgcode : CARDINAL;
  401.   msgclass : IDCMPFlagsSet;
  402.   foo : BOOLEAN;
  403.  
  404. BEGIN   (*******************************************)
  405.         (* First, check to see if the game is over *)
  406.         (*******************************************)
  407.   IF gameover THEN
  408.      REPEAT
  409.         GetPrimitiveEvent(msgcode, msgclass);
  410.      UNTIL MenuPick IN msgclass;
  411.      RETURN ProcessMenuPick(msgcode);
  412.      END;
  413.  
  414.         (*************************)
  415.         (*  get the from square  *)
  416.         (*************************)
  417. REPEAT                          (* loop until mouse down in right place *)
  418.      GetPrimitiveEvent(msgcode, msgclass);
  419.  
  420.   IF MenuPick IN msgclass THEN     (* Or there's a menu selection.     *)
  421.      RETURN ProcessMenuPick(msgcode);
  422.      END;
  423.  
  424. UNTIL (msgcode = SelectDown) AND
  425.       (TransCoordToBoard(mousex, mousey,
  426.         moveAttempted.fromX, moveAttempted.fromY) = TRUE) AND
  427.       (state.board[moveAttempted.fromX, moveAttempted.fromY] = player);
  428.  
  429. HighlightSquare(moveAttempted.fromX, moveAttempted.fromY, player);
  430. IF state.turn = red THEN
  431.   ChangePointer(RedCircle);
  432.   ELSE ChangePointer(BlueCircle);
  433.   END;
  434.  
  435.         (***********************)
  436.         (* Get the dest sqaure *)
  437.         (***********************)
  438.  
  439. REPEAT
  440.      GetPrimitiveEvent(msgcode, msgclass);
  441. UNTIL msgcode = SelectUp;
  442. foo := TransCoordToBoard(mousex, mousey,
  443.         moveAttempted.toX, moveAttempted.toY);
  444.  
  445. UnHighlightSquare(moveAttempted.fromX,moveAttempted.fromY, player);
  446.  
  447. RETURN MOVE;
  448.  
  449. END GetEvent;
  450.  
  451. (**************************************************************************)
  452. PROCEDURE EditBoard (VAR board : boardtype; VAR player : playertype)
  453.               : BOOLEAN;
  454.  
  455. (*   This procedure controls all the necessary input and outputs for mod- *)
  456. (* ifying the board and returns whether or not any changes were made.     *)
  457. (*                                                                        *)
  458. (*   INPUT                                                                *)
  459. (*            board             The current board.                        *)
  460. (*                                                                        *)
  461. (*            player            The current player to move.  This is      *)
  462. (*                              needed to return the pointer to the old   *)
  463. (*                              state.                                    *)
  464. (*                                                                        *)
  465. (*   OUTPUT                                                               *)
  466. (*            board             This is returned reflecting the modified  *)
  467. (*                              state.                                    *)
  468. (*                                                                        *)
  469. (*            The function returns TRUE only if the board was actually    *)
  470. (*            altered.  A return of FALSE signifies that no changes were  *)
  471. (*            made to the board.                                          *)
  472.  
  473. VAR
  474.   done : BOOLEAN;
  475.   modified : BOOLEAN;
  476.   msgcode : CARDINAL;
  477.   msgclass : IDCMPFlagsSet;
  478.   menunumber, itemnumber : CARDINAL;
  479.   backupboard : boardtype;
  480.   backupplayer : playertype;
  481.   boardx, boardy, i, j : boardrange;
  482.  
  483. BEGIN
  484.   CASE editpointerstate OF
  485.      | empty  :
  486.         ChangePointer(EmptySquare);
  487.      | block  :
  488.         ChangePointer(BlockSquare);
  489.      | red    :
  490.         ChangePointer(RedCircle);
  491.      | blue   :
  492.         ChangePointer(BlueCircle);
  493.      END;
  494.  
  495.   backupboard := board;
  496.   backupplayer := player;
  497.   done := FALSE;
  498.   modified := FALSE;
  499.  
  500.   REPEAT
  501.      GetPrimitiveEvent(msgcode, msgclass);
  502.  
  503.      IF MenuPick IN msgclass THEN        (* Doing menu selection *)
  504.         menunumber := MENUNUM(msgcode);
  505.         itemnumber := ITEMNUM(msgcode);
  506.         CASE menunumber OF
  507.            |  0  :
  508.               CASE itemnumber OF
  509.                  |  0  :                    (* quit *)
  510.                     done := TRUE;
  511.                  END;  (* case itemnumber *)
  512.  
  513.            |  1  :
  514.               CASE itemnumber OF
  515.                  |  0  :
  516.                     IF player # red THEN
  517.                        player := red;
  518.                        PrintTurn(player);
  519.                        modified := TRUE;
  520.                        END;
  521.  
  522.                  |  1  :
  523.                     IF player # blue THEN
  524.                        player := blue;
  525.                        PrintTurn(player);
  526.                        modified := TRUE;
  527.                        END;
  528.                  END;
  529.  
  530.            |  2  :
  531.               CASE itemnumber OF
  532.                  |  0  :                    (* blank square *)
  533.                     ChangePointer(EmptySquare);
  534.                     editpointerstate := empty;
  535.  
  536.                  |  1  :
  537.                     ChangePointer(BlockSquare);
  538.                     editpointerstate := block;
  539.  
  540.                  |  2  :
  541.                     ChangePointer(RedCircle);
  542.                     editpointerstate := red;
  543.  
  544.                  |  3  :
  545.                     ChangePointer(BlueCircle);
  546.                     editpointerstate := blue;
  547.                  END;  (* case itemnumber *)
  548.  
  549.            |  3  :
  550.               CASE itemnumber OF
  551.                  |  0  :                          (* cancel changes *)
  552.                     board := backupboard;
  553.                     player := backupplayer;
  554.                     PrintTurn(player);
  555.                     modified := FALSE;
  556.                     ChangeToEditMenu;
  557.                     DrawBoard (board);
  558.  
  559.                  |  1  :                          (* make 'em all empty *)
  560.                     FOR i := 1 TO 7 DO
  561.                        FOR j := 1 TO 7 DO
  562.                           board[i,j] := empty;
  563.                           END;
  564.                        END;
  565.                     modified := TRUE;
  566.                     DrawBoard (board);
  567.  
  568.                  |  2  :                          (* make 'em all blocks *)
  569.                     FOR i := 1 TO 7 DO
  570.                        FOR j := 1 TO 7 DO
  571.                           board[i,j] := block;
  572.                           END;
  573.                        END;
  574.                     modified := TRUE;
  575.                     DrawBoard (board);
  576.  
  577.                  END;  (* case itemnumber *)
  578.            END;  (* case menunumber *)
  579.  
  580.  
  581.         ELSE                             (* Not a menu, but a click! *)
  582.            IF (msgcode = SelectUp) AND   (* only want an UP mouse button  *)
  583.                  TransCoordToBoard(mousex, mousey, boardx, boardy) THEN
  584.               board[boardx, boardy] := editpointerstate;
  585.               DrawSquare(boardx, boardy, editpointerstate);
  586.               modified := TRUE;
  587.               END;
  588.         END;
  589.  
  590.   UNTIL done;
  591. (*
  592.   IF player = red THEN                   (* Revert the pointer   *)
  593.      ChangePointer(RedPointer);
  594.      ELSE ChangePointer(BluePointer);
  595.      END;
  596. *)
  597.   RETURN modified;
  598.  
  599. END EditBoard;
  600.  
  601.  
  602. (**************************************************************************)
  603. PROCEDURE WaitForMouseUp;
  604.  
  605. (*   This simple procedure just waits until the left mouse button is re-  *)
  606. (* leased.                                                                *)
  607. VAR
  608.   msgcode : CARDINAL;
  609.   msgclass : IDCMPFlagsSet;
  610.  
  611. BEGIN
  612.   REPEAT
  613.      GetPrimitiveEvent(msgcode, msgclass);
  614.   UNTIL msgcode = SelectUp;
  615. END WaitForMouseUp;
  616.  
  617. (******************************************************************)
  618.  
  619. BEGIN
  620.   editpointerstate := empty;
  621. END input.
  622.